﻿using System;

namespace EmbeddedSharp.Core.Function.Administration {
    public class ReloadNode : FuncNode {

        public ReloadNode()
            : base() {
            base.Value = "reload";
        }

        public override object Evaluate() {
            if(Parameters.Count == 0) {
                throw new ArgumentException(
                   "Usage: reload(assemblyName)");
            }

            DefaultFunctionLoader loader = new DefaultFunctionLoader(
            DefaultDependencyManager.Instance.FunctionManager);
            loader.LoadFromFile(
                Parameters[0].Evaluate().ToString());

            return string.Empty;
        }
    }
}
